using System;
using System.Collections.Concurrent;
using System.Linq;

using ApiTest.Entitys;

using Apps.Shared.IServices;

using MicroMq.Core;

using Utils;

namespace ApiTest.Services
{
    [Injection, JobService, Consumer]
    public class GoodsService : Mdb<Goods>, IGoodsService
    {
        public readonly MicroProducer microProducer;

        [AppRun]
        [Dispatcher("0/5 * * * * ? *")]
        public void Run()
        {
            Console.WriteLine("send:" + DateTime.Now.ToString("mm-ss fff"));
           // microProducer.Send("test", "tes222222222222222222222t");
        }

        [Listen("test")]
        public void Listen(string msg)
        {
            Console.WriteLine("Listen" + DateTime.Now.ToString("mm-ss fff"));
            Console.WriteLine(msg);
        }


        public Goods Test()
        {
            return Query
                .Where(a => a.IsDel == false)
                .OrderByDescending(a => a.GoodsId)
                .FirstOrDefault();
        }
    }
}

